<template>
    <div class="user-container">
        <div class="user-photo" v-for="item in datas">
            <el-image style="border-radius: 10px;position: absolute;height: 200px;width: 320px;"
                :src="api.show + imageUrl(item.fileId)" @click="toPhoto(item.photoId)">
            </el-image>
            <div class="photo-info">
                <p>{{ item.name }}</p>

            </div>
        </div>

    </div>
</template>
<script setup>
import { useRoute, useRouter } from 'vue-router'
import { ref, watch } from 'vue'
import api from './api.js'
import '@/assets/iconfont.js'
const route = useRoute()
const router = useRouter()
const imageUrl = (images) => {
    const image = images.split(',')
    return image[0]
}

const datas = ref([])
const search = ref({
    index: 1,
    size: 8,
    name: '',
    total: 0
})

watch(
    () => route.params.id,
    (newId, oldId) => {
        search.value.userId = newId
        watchByMyself()
    }
);





const paginChange = (value) => {
    search.value.index = value
    watchByMyself()
}
const toPhoto = (id) => {
    router.push({ name: 'photo', params: { id: id } })
}

const watchByMyself = () => {
    api.watchByMyself(search.value).then(res => {
        if (res.success) {
            datas.value = res.datas
            search.value.total = res.total

            console.log(res.total)
        }
    })
}
watchByMyself()

console.log(1231231)
</script>

<style>
.pagination {
    width: 100%;
    background-color: white;
    height: 60px;
    border-radius: 10px;
    position: relative;
}

.pagination .pagination-page {
    position: absolute;
    top: 20px;
    left: 30px;
}

.user-container {
    width: 100%;
    height: 80%;
    padding: 15px;
    display: flex;
    justify-content: start;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.user-container .user-photo {
    margin: 10px 20px;
    height: 260px;
    width: 320px;
    background-color: #e1ecfc;
    position: relative;
}

.user-container .user-photo:hover {
    cursor: pointer;
}

.user-container .user-photo .photo-info {
    top: 210px;
    left: 10px;
    position: absolute;
    font-size: 13px;
    color: #333;
    width: 90%;
}

.user-container .user-photo .info-statistics {
    position: absolute;
    /* right: 0; */
    top: 225px;
    left: 10px;
    font-size: 12px;
    line-height: 23px;
    color: #666;
    display: flex;
    justify-content: space-between;
}

.user-container .user-photo .photo-time {
    position: absolute;
    height: 23px;
    font-size: 12px;
    line-height: 23px;
    top: 225px;
    color: #666;
    right: 30px;
}

.user-container .user-photo .photo-button {
    position: absolute;
    top: 260px;
    right: 20px
}
</style>